package com.atguigu03;

import com.atguigu02.memory.Person;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class ListTest {
    public static void main(String[] args) {
        List list=new ArrayList();
        list.add(123);//自动装箱
        list.add(2);//自动装箱
        list.add("456");
        list.add(new Person("tom",23));
//删除索引2，因为要避免拆箱的操作
        list.remove(2);
        System.out.println(list);
        //删除数据2
        list.remove(Integer.valueOf(2));
        System.out.println(list);

        Iterator iterator=list.iterator();
        while(iterator.hasNext()){
            System.out.println(iterator.next());
        }


    }
}
